﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration;

namespace Artech.EnterLibExt.ExceptionHandling.Configuration
{
    public class ExceptionFilterTableData : NamedConfigurationElement
    {
        private const string FilterPropertyName     = "filter";
        private const string HandlersPropertyName   = "exceptionHandlers";
        private const string PriorityPropertyName   = "priority";

        [ConfigurationProperty(FilterPropertyName, IsRequired = true)]
        public string Filter
        {
            get { return (string)this[FilterPropertyName]; }
            set { this[FilterPropertyName] = value; }
        }

        [ConfigurationProperty(HandlersPropertyName,IsRequired = true)]
        public NameTypeConfigurationElementCollection<ExceptionHandlerData, CustomHandlerData> ExceptionHandlers
        {
            get{return (NameTypeConfigurationElementCollection<ExceptionHandlerData, CustomHandlerData>)this[HandlersPropertyName];}
            set { this[HandlersPropertyName] = value; }
        }

        [ConfigurationProperty(PriorityPropertyName, IsRequired = false, DefaultValue = 0)]
        public int Priority
        {
            get { return (int)this[PriorityPropertyName]; }
            set { this[PriorityPropertyName] = value; }
        }
    }
}